package MathTextModeller
{
	import MathText.WordProblem;
	
	import MyDisplayObjects.ClickableImage;

	public class ChangeFace extends ToolFace
	{
		public static const COLOR:uint = 0xFFFFEE; 
		public static const BUTTON_COLOR:uint = 0xFFF2F2;
		
		public function ChangeFace(width:Number, height:Number, sentenceToolsXML:XML, wordProblem:WordProblem)
		{
			super(width, height, COLOR, sentenceToolsXML, wordProblem);
			this._type = "change";
			placeButtons();
		}
		
		/** This function is used to place buttons on this face of the tool, by running through the XML */
		private function placeButtons():void
		{
			var Y_BORDER:Number = (this.HEIGHT - this.HEIGHT*5/6)/4; 
			// place subject 1 in top-left
			this.buttons = new Array();
			var button:ClickableImage;
			
			button = new ClickableImage(this.WIDTH*3/8, this.HEIGHT*1/3, this.sentenceToolsXML..subject1[0], wordProblem.subject1.name, this.WIDTH/15, BUTTON_COLOR, true);
			button.name = "subject1";
			button.x = (this.WIDTH/2 - button.width)/2;
			button.y = Y_BORDER;
			this.buttons.push(button);
			this.addChild(button);	
			
			button = new ClickableImage(this.WIDTH*3/8, this.HEIGHT*1/3, this.sentenceToolsXML..subject2[0], wordProblem.subject2.name, this.WIDTH/15, BUTTON_COLOR, true);
			button.name = "subject2";
			this.buttons.push(button);
			button.x = this.WIDTH/2 + (this.WIDTH/2 - button.width)/2;
			button.y = Y_BORDER;
			this.addChild(button);	
			
			var changeString:String
			button = new ClickableImage(this.WIDTH*3/4, this.HEIGHT*1/3, this.sentenceToolsXML..changed[0], wordProblem.subject1.getAnyAVerb(), this.WIDTH/15, BUTTON_COLOR, true);
			button.name = "changed";
			this.buttons.push(button);
			button.x = (this.WIDTH - button.width)/2;
			button.y = this.buttons[this.buttons.length - 2].y + this.buttons[this.buttons.length - 2].height + Y_BORDER;
			this.addChild(button);
			
			button = new ClickableImage(this.WIDTH*3/8, this.HEIGHT*1/6, this.sentenceToolsXML..unit[0], wordProblem.subject1.getAnyUnit(), this.WIDTH/15, BUTTON_COLOR, false);
			button.name = "unit";
			this.buttons.push(button);
			button.x = (this.WIDTH/2 - button.width)/2;
			button.y = this.buttons[this.buttons.length - 2].y + this.buttons[this.buttons.length - 2].height + Y_BORDER;
			this.addChild(button);
			
			button = new ClickableImage(this.WIDTH*3/8, this.HEIGHT*1/6, this.sentenceToolsXML..unknown[0], "unknown", this.WIDTH/15, BUTTON_COLOR, true);
			button.name = "unknown";
			this.buttons.push(button);
			button.x = this.WIDTH/2 + (this.WIDTH/2 - button.width)/2;
			button.y = this.buttons[this.buttons.length - 3].y + this.buttons[this.buttons.length - 3].height + Y_BORDER;
			this.addChild(button);
		}
	}
}